package com.dongdongshop.controller;

import com.dongdongshop.data.Result;
import com.dongdongshop.service.SMSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sms")
@CrossOrigin  //跨域
@RefreshScope   //自动监听配置文件
public class SMSController {

    @Autowired
    private SMSService smsService;

    @PostMapping("sendPhoneMessage")
    public Result sendPhoneMessage(String phoneNum){
        try {
            smsService.sendPhoneMessage(phoneNum);
            return Result.OK();
        } catch (Exception e) {
            return Result.FALL().setData("手机号格式错误");
        }
    }

}
